package com.atguigu.gmall.realtime.flink.demo;

import com.atguigu.gmall.realtime.flink.util.MyKafkaUtil;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.connectors.kafka.FlinkKafkaConsumer;

public class KafkaDemoApp {


    public static void main(String[] args) throws Exception {
        // 环境
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        FlinkKafkaConsumer<String> kafkaConsumer = MyKafkaUtil.getKafkaConsumer("topic_log", "demo_kafka");
        DataStreamSource<String> kafkaStream = env.addSource(kafkaConsumer);

        kafkaStream.print();

        env.execute();

    }
}
